//
//  SPLiveDetailGoodsHeaderFooterView.m
//  panzer
//
//  Created by 还带大道 on 2018/10/22.
//  Copyright © 2018年 还带大道. All rights reserved.
//

#import "SPLiveDetailGoodsHeaderFooterView.h"
#import "SPCommon.h"
#import "SPGoodsCellTableViewCell.h"
#import "SPGoodsModel.h"

@interface SPLiveDetailGoodsHeaderFooterView()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UIView *bgV;

@end

@implementation SPLiveDetailGoodsHeaderFooterView


- (void)awakeFromNib
{
    [super awakeFromNib];
    [self setupShadow];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([SPGoodsCellTableViewCell class]) bundle:nil]  forCellReuseIdentifier:NSStringFromClass([SPGoodsCellTableViewCell class])];
}


+ (instancetype)shareHeaderView
{
    return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].lastObject;
}


- (void)setupShadow
{
    _bgV.layer.shadowColor = RZ_COLOR_ALPHA(201, 201, 201, 0.37).CGColor;
    _bgV.layer.cornerRadius = 5;
    _bgV.layer.shadowOffset = CGSizeMake(0,1);//shadowOffset阴影偏移,x向右偏移，y向下偏移，默认(0, -3)
    _bgV.layer.shadowOpacity = 1;//阴影透明度，默认0
    _bgV.layer.shadowRadius = 4;//阴影半径，默认3
}

- (void)setGoods_list:(NSArray<SPGoodsModel *> *)goods_list
{
    _goods_list = goods_list;
    [self.tableView reloadData];
}


#pragma mark--

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _goods_list.count;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 85;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SPGoodsCellTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SPGoodsCellTableViewCell class])];
    cell.model = self.goods_list[indexPath.row];
    return cell;
}

@end
